home *** CD-ROM | disk | FTP | other *** search
- Path: saluki-news.wham.siu.edu!usenet
- From: <agent@siu.edu>
- Newsgroups: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
- Subject: Re: 6502 Multitasking OS announce
- Date: 25 Mar 1996 04:46:09 GMT
- Organization: Southern Illinois University
- Message-ID: <4j58eh$btc@saluki-news.wham.siu.edu>
- References: <4i94fs$stj@narses.hrz.tu-chemnitz.de> <holger.948.00030EE6@deep.hb.provi.de> <4ijtbe$7ca@no-names.nerdc.ufl.edu> <4ijuic$iiq@gatekeeper.liffe.com> <4innc7$hc4@no-names.nerdc.ufl.edu> <4itkri$qlc@seagoon.newcastle.edu.au>
- NNTP-Posting-Host: mac0160.clc1.siu.edu
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: quoted-printable
- X-Mailer: Mozilla 1.1N (Macintosh; I; PPC)
- X-URL: news:4itkri$qlc@seagoon.newcastle.edu.au
-
- How about this idea, to handle stacks? I read a similar thing in an
- issue of Dr. Dobbs Journal, in an article about a small multitasker.
-
- Given that the stack is mostly going to be used for minor parameter
- passing and jsr's. I think is a good assumption -- other data
- structures are better suited for larger jobs.
-
- Instead of copying the stack to and fro on every task switch, how about
- subdividing it? Each task would be allocated a portion of the stack. A
- task switch moves between the portions by adding or subtracting numbers
- from the stack register.
-
- For example, let's say that we are currently on task 1. Its stack is
- partially filled. The stack register holds 240. Now there is a task
- switch, to task 2. The interrupt service routine stores the depth of
- the stack register on task 1's stack, which in this case, is 16. Now,
- the OS has also recorded where task 2's stack pointer was the last time
- it was active, in the format of 192 - n. It loads up n, subtracts it
- from 192, stores that in the stack register, giving xxx in the diagram
- below (the correct stack entry), and executes an RTI. It will return to
- the appropriate point in task 2, because task 2 was halted by an
- Jump-to-Interrupt (forgot opcode) to the OS, and the last thing put on
- the stack was the return address to task 2's state. So the RTI will
- return to that state.
-
- Now, how to handle allocation of the stack? Well, some routines,
- particularly those needing recursion, need a lot of stack. Others don't
- need much. So when a task is initiated, it can request how much it
- expects to need, and the OS can allocate such-and-so.
-
- 256 -----------------
- : Task 1 <- 240: 256-16
- :
- 192 -----------------
- : Task 2 <- xxx: 192-n=03
- :
- 144 -----------------
- : Task 3 (small)
- 112 -----------------
- : Task 4 (wants
- : lots)
- :
- 48 -----------------
- : System
- : or Free
- =050 -----------------
-
- What do you think? Is it workable? (Again, due credits to Dr. Dobbs'
- article by whoever wrote it.)
-
-
-